//
//  LoginViewModel.m
//  AppointmentForCar
//
//  Created by TheMacBook on 2016/11/7.
//  Copyright © 2016年 Herron. All rights reserved.
//

#import "LoginViewModel.h"
#import "UserModel.h"
@implementation LoginViewModel

- (void)loginUserName:(NSString *)username code:(NSString *)code complete:(CompleteBackCallBlock)complete {
    [NetWork postNetWorkWithUrl:@"driver-login" parame:@{@"driverphoneNumber":username,@"verifyCode":code} successBlock:^(NSDictionary *dic) {
        NSLog(@"登录dic = %@", dic);
        if([dic[@"status"] integerValue] == 0) {
            [[UserAccountManager shareUserManager] loginWithUserDic:dic[@"data"]];
            complete(nil);
        } else {
            [HUDManager showWarningWithText:dic[@"message"]];
            complete(dic[@"message"]);
        }
    } errorBlock:^(id error) {
        complete(error);
    }];
}

- (void)getPhoneVerificationCodeWithPhone:(NSString *)phone complete:(CompleteBackCallBlock)complete
{
    [NetWork postNetWorkWithUrl:@"get-verifycode" parame:@{@"phoneNumber":phone} successBlock:^(NSDictionary *dic) {
        NSLog(@"dic = %@", dic);
    } errorBlock:^(id error) {
        
    }];
}
@end
